<?php
		echo $this->Html->css(array(
			'ui.jqgrid','redmond/jquery-ui-1.10.3.custom.min.css', /*jquery-ui-icons jqgrid依赖jqueryui的部分图标*/
		));
?>
<?php

        echo $this->Html->script(array(
            'jquery/jquery-ui-1.10.3.custom.min.js',
			'jquery/jquery.jgrowl.min.js',
			'jqgrid/i18n/grid.locale-cn',
        	'jqgrid/jquery.jqGrid.min.js',
			'i18n/language-zh-cn',
        ));
?>

<style>

.btn{margin:2px;}

#stats-date{width:150px;}
.affix {
	position: fixed;top:0px;
	z-index: 10000;
}
</style>
<p>
{{loop $contentmodels $model}}
	<a class="btn {{if $_REQUEST['model']==$model['Modelextend']['name']}}btn-primary{{else}}btn-default{{/if}}" href="/admin/stats_days/lists?model={{$model['Modelextend']['name']}}&date={{$_REQUEST['date']}}">{{$model['Modelextend']['cname']}}</a>
{{/loop}}
</p>
<input class="form-control" type="date" id="stats-date" value="{{$_REQUEST['date']}}">

<p>本页总次数：{{$total}}</p>
<section style="margin:10px auto;width:100%;">
<table id="list4" ></table>
</section>



<script>

$(function(){

	$(document).on('change','#stats-date',function(){
		window.location.href= '/admin/stats_days/lists?model={{$_REQUEST['model']}}&date='+$(this).val();
	});

	// $('.ui-jqgrid-htable').affix({
	//     offset: {
	//         top: 400
	//     }
	// });

	// $(window).resize(function(){
	// 	console.log('resize');
	// 	jQuery("#list4").jqGrid( 'setGridWidth',$('#maincontent').width()-60 ); // window
		
	// 	return;
	// }).trigger('resize');
		
})

jQuery("#list4").jqGrid({
	datatype: "local",
	height: 'auto',
   	colNames:[
   		{{loop $headers $k $name}}
   		'{{$name}}',
   		{{/loop}}
   		'操作'
   	],
   	colModel:[
   		{{loop $headers $k $name}}
   		{name:'{{$k}}',align:"center",index:'{{$k}}'{{if in_array($k,array('id','view_nums'))}},sorttype:"float"{{/if}}},
   		{{/loop}}
   		{name:'actions',index:'actions', sortable:false}
   		/*
   		{{if in_array($k,array('star','readed','status'))}},width:80{{/if}}
   		
   		{name:'invdate',index:'invdate', width:90, sorttype:"date"},
   		{name:'name',index:'name', width:100},
   		{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
   		{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},		
   		{name:'total',index:'total', width:80,align:"right",sorttype:"float"},		
   		{name:'note',index:'note', width:150, sortable:false}	*/	
   	],
   	multiselect: false,
   	caption: false
});
var mydata = <?php echo json_encode($datas) ?>;
for(var i=0;i<mydata.length;i++){
	
	jQuery("#list4").jqGrid('addRowData', mydata[i].id , mydata[i]);
}



</script>